-- bishop_prop
-- create by shuzy
-- 技能带来一条附加属性(主教召唤兽专用)
--     prop(1,20,5)：第一个参数为prop_id、第二个参数为prop的数值、第三个参数为回合数（如果没有默认为一直起效）
-- 附加属性都记录在目标的prop/skill字段下，战斗开始或结束时将被删除，每回合开始时处理一遍(过期的删掉)

return {
    apply = function(source, target, skillId, round, para, extra)
        local effectRound = -1;
        extra = extra or {};
        local lastRound = extra.lastRound;

        if type(lastRound) == "number" then
            effectRound = round + lastRound;
        elseif para[4] > 0 then
            effectRound = round + para[4];
        end

        assert(source.type == OBJECT_TYPE_BISHOP);
        local level = source:getSkillLevel(skillId);
        level = math.max(1, level);

        local prop = { para[1], para[2], para[3] * level, effectRound, }

        -- 记录属性
        PropM.record(target, prop, "skill")

        -- 作用目标
        return { target, };
    end,

    parse = function(desc)
        local arr = string.explode(desc, ",");
        return { tonumber(arr[1]), arr[2], tonumber(arr[3]), tonumber(arr[4] or -1), };
    end,

    -- 解析技能描述
    parseDesc = function(source, skillId, desc, para)
        local bishop = source.bishop;
        if not bishop then
            return "";
        end

        local level = bishop:getSkillLevel(skillId);
        level = math.max(1, level);
        local v = para[3] * level;

        if PropM.getRow(para[1])["type"] == PROP_TYPE_RATIO then
            -- 小数
            v = v / 10;
        end

        desc = string.gsub(desc, "{prop}", v, 1);

        return desc;
    end,
};
